<template>
  <div class="demoCollapse">
    <el-table :data="tableData" style="width: 100%">
      <el-table-column type="expand">
        <template #default="">
          <div class="box" v-for="(item, index) in tableData" :key="index">
            <div class="photo" :style="{ background: `${item.img}` }"></div>
            <div class="message">
              <p class="name">
                {{ item.name }}
              </p>
              <p class="job">
                {{ item.job }}
              </p>
            </div>
          </div>
        </template>
      </el-table-column>
      <el-table-column prop="date" />
    </el-table>
  </div>
</template>

<script>
import { ElTable, ElTableColumn } from "element-plus";
import service from "../../../../mock/index1";
import { onMounted, ref } from "vue";
export default {
  setup() {
    let tableData = ref([]);
    onMounted(async () => {
      const res = await service.getData();
      tableData.value = res.data.data;
    });
    return {
      tableData,
    };
  },
  components: {
    ElTable,
    ElTableColumn,
  },
};
</script>

<style lang='less' spoced>
.box {
  width: 100%;
  height: 55px;
  display: flex;
  padding-left: 30px;
  background-color: #ebebeb;
  margin-bottom: 5px;
  &:hover {
    background-color: rgb(188, 192, 192);
  }
  .photo {
    width: 55px;
    height: 55px;
    background-color: aqua;
    margin-right: 5px;
  }
  .message {
    .name {
      font-size: 18px;
      color: #000;
      margin-bottom: 10px;
    }
  }
}
.el-table td.el-table__cell,
.el-table th.el-table__cell.is-leaf {
  border-bottom: none;
}
.el-table__header-wrapper {
  display: none;
}
.demoCollapse {
  width: 100%;
}
.el-table__expanded-cell {
  background-color: #ebebeb;
}
</style>